VB怎么获取文件创建时间```

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:53:48
比如说我想得知C:\123.exe 创建时间,要怎么做呢?

Set fs = CreateObject("Scripting.FileSystemObject") '创建FileSystemObject 对象
Set f = fs.GetFile("C:\123.exe ") '返回指定路径文件所对应的 File 对象
'File 对象的 DateCreated 属性返回该文件夹的创建日期和时间
'File 对象的 DateLastModified 属性返回最后一次修改该文件的日期和时间
'File 对象的 DateLastAccessed 属性返回最后一次访问该文件的日期和时间
MsgBox "创建时间:" & f.DateCreated & vbCrLf & "修改时间:" & f.DateLastModified & vbCrLf & "访问时间:" & f.DateLastAccessed, vbInformation, f.Name & "属性"

Dim ObjFileSystem As New FileSystemObject '需引用Microsoft Scripting Runtime
Dim ObjFile As File
Set ObjFile = ObjFileSystem.GetFile(App.Path & "y.doc") '文件名
Debug.Print ObjFile.DateCreated '文件创建时间
Debug.Print ObjFile.DateLastAccessed '文件访问时间
Debug.Print ObjFile.DateLastModified '文件修改时间

msgbox FileDateTime(“D:\123.txt”)'获取文件最后修改的时间
Sub ShowFileInfo(filespec)'